package client;

import java.util.Queue;
import java.util.Vector;

public class ClientModel {
	public static final float BASE_SPEED = 1; /* cell per measure unit of Tick */ 
	
	private Queue<InputType> inputs;
	private Block[][] gameGrid;
	private MovingBlock nextBlock;
	private MovingBlock currentBlock;
	private Vector<Block> otherBlocks;
	
	public ClientModel() {
		gameGrid = new Block[50][10];
		for (int i=0; i<gameGrid.length; i++) {
			for (int j=0; j<gameGrid[i].length; j++) {
				gameGrid[i][j] = null;
			}
		}
		createFirstSetOfBlocks();
	}

	public boolean update() {
		if(inputs.isEmpty()) {
			return true;
		}
		InputType commandToBeRead = inputs.poll();
		commandIntepreter(commandToBeRead);
		Tick elapsedTime = new Tick(actual, previous);
		currentBlock.updatePosition(elapsedTime);
		return true;
	}

	private void commandIntepreter(InputType commandToBeRead) {
		switch (commandToBeRead) {
		case LEFT:
			currentBlock.moveLeft();
			break;
		case RIGHT:
			currentBlock.moveRight();
		case ROTATE:
			currentBlock.rotate();
		case DOWN:
			currentBlock.scrollDown();			
		}
	}
	
	private void createFirstSetOfBlocks() {
		// TODO Auto-generated method stub
		
	}
}
